<?php
namespace Home\Controller;
use Think\Controller;


class BaseController extends Controller {

	
	function _initialize(){
		$account = session('account');
		$userinfo = M('user')->where('username="%s"',$account)->find();
		
		if(!$userinfo){
			$url =   $_SERVER['PHP_SELF'].'?'.$_SERVER['QUERY_STRING'];
			cookie('from_url',$url);	
			
			$this->redirect('/Home/Login/login');
		}else{
			$this->userinfo = $userinfo;
			$this->account = $account;
			$this->user_id = $userinfo['id'];	
			$this->headimg = $userinfo['headimg'];	
			$this->nickname = $userinfo['nickname'];
			$this->assign('nickname',$this->nickname);
			$this->assign('headimg',$this->headimg);	
			
			$upload = M('filelist')->where('user_id =  %d',	$this->user_id )->count();
			$this->assign('upload',$upload);	
			
		}
		
		
		
	}
	  

}